package com.lafengmaker.vo;

import java.io.Serializable;

/**
 * @author lafengmaker
 * @title: ResponseDTO
 * @projectName demo
 * @description: TODO
 * @email yeweijun@souche.com
 * @date 1/21/21 9:49 AM
 */
public class ResponseDTO<T>  implements Serializable {
    private T data;
    private boolean success;
    private String code;

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public static ResponseDTO success(Object data){
        ResponseDTO responseDTO=new ResponseDTO();
        responseDTO.setData(data);
        responseDTO.setCode("200");
        responseDTO.setSuccess(true);
        return responseDTO;
    }
    public static ResponseDTO fail(Object data){
        ResponseDTO responseDTO=success(data);
        responseDTO.setData(data);
        responseDTO.setCode("500");
        responseDTO.setSuccess(false);
        return responseDTO;
    }
}
